/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JF_CitacionesAdmin.java
 *
 * Created on 20-mar-2010, 16:47:56
 */

package cliente.presentacion.administrador.citas;

import javax.swing.JOptionPane;

import cliente.negocio.Controlador_Gestion_Cistas;
import java.awt.Toolkit;
import java.util.Date;
import server.dominio.Beneficiario;
import server.dominio.Medico;

/**
 *
 * @author greenbite
 */
public class JF_CitacionesAdmin extends javax.swing.JFrame implements iJF_CitacionesAdmin{
    private Controlador_Gestion_Cistas G_citas;
    /** Creates new form JF_CitacionesAdmin */
    public JF_CitacionesAdmin(Controlador_Gestion_Cistas G_citas) {
        initComponents();
        this.setLocation((int)Toolkit.getDefaultToolkit().getScreenSize().getWidth()/4,(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()/6);
        this.G_citas= G_citas;
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jButton_borrarcita = new javax.swing.JButton();
        jButton_anadircita = new javax.swing.JButton();
        jLayeredPane4 = new javax.swing.JLayeredPane();
        jCalendar_citas = new org.freixas.jcalendar.JCalendar();
        jLayeredPane5 = new javax.swing.JLayeredPane();
        jTextField_selecnif = new javax.swing.JTextField();
        jButton_buscar = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTextField_selecnss = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLayeredPane7 = new javax.swing.JLayeredPane();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTable_citas = new javax.swing.JTable();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        jLabel23 = new javax.swing.JLabel();
        jTextField_ano = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jTextField_email = new javax.swing.JTextField();
        jTextField_dia = new javax.swing.JTextField();
        jTextField_mes = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jTextField_Nombre = new javax.swing.JTextField();
        jTextField_Apellido = new javax.swing.JTextField();
        jTextField_domicilio = new javax.swing.JTextField();
        jTextField_telefonofijo = new javax.swing.JTextField();
        jTextField_telmovil = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jTextField_med_Nif1 = new javax.swing.JTextField();
        jTextField_medi_Nombre1 = new javax.swing.JTextField();
        jTextField_medi_apellidos1 = new javax.swing.JTextField();
        jButton_volantes = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Atras");

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/imagen_corporativa2.png"))); // NOI18N
        jLabel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/1269099339_Back.png"))); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Menu Citacion"));

        jButton_borrarcita.setText("Borrar Cita");
        jButton_borrarcita.setEnabled(false);
        jButton_borrarcita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_borrarcitaActionPerformed(evt);
            }
        });

        jButton_anadircita.setText("Añadir Cita");
        jButton_anadircita.setEnabled(false);
        jButton_anadircita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_anadircitaActionPerformed(evt);
            }
        });

        jLayeredPane4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Selección de medico"));

        jCalendar_citas.setEnabled(false);
        jCalendar_citas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jCalendar_citasMouseClicked(evt);
            }
        });
        jCalendar_citas.addDateListener(new org.freixas.jcalendar.DateListener() {
            public void dateChanged(org.freixas.jcalendar.DateEvent evt) {
                jCalendar_citasDateChanged(evt);
            }
        });
        jCalendar_citas.setBounds(20, 30, 330, 200);
        jLayeredPane4.add(jCalendar_citas, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Selección de medico"));
        jTextField_selecnif.setBounds(130, 40, 110, 20);
        jLayeredPane5.add(jTextField_selecnif, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton_buscar.setText("Buscar");
        jButton_buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_buscarActionPerformed(evt);
            }
        });
        jButton_buscar.setBounds(270, 40, 110, 60);
        jLayeredPane5.add(jButton_buscar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel15.setText("NIF Beneficiario:");
        jLabel15.setBounds(10, 40, 100, 16);
        jLayeredPane5.add(jLabel15, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setText("NSS Beneficiario");
        jLabel9.setBounds(10, 80, 100, 16);
        jLayeredPane5.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField_selecnss.setBounds(130, 80, 110, 22);
        jLayeredPane5.add(jTextField_selecnss, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cita_icon.png"))); // NOI18N

        jLayeredPane7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Citas del dia"));

        jTable_citas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"8", null, null},
                {"9", null, null},
                {"10", null, null},
                {"11", null, null},
                {"12", null, null},
                {"13", null, null},
                {"14", null, null},
                {"15", null, null},
                {"16", null, null},
                {"17", null, null},
                {"18", null, null},
                {"19", null, null}
            },
            new String [] {
                "Hora", "Estado", "Citado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Boolean.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable_citas.setAutoscrolls(false);
        jTable_citas.setCellSelectionEnabled(true);
        jTable_citas.setEnabled(false);
        jTable_citas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane7.setViewportView(jTable_citas);
        jTable_citas.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jTable_citas.getColumnModel().getColumn(0).setResizable(false);
        jTable_citas.getColumnModel().getColumn(2).setResizable(false);

        jScrollPane7.setBounds(20, 40, 220, 190);
        jLayeredPane7.add(jScrollPane7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Datos personales"));

        jLabel23.setText("Fecha de nacimiento:");
        jLabel23.setBounds(20, 200, 130, 16);
        jLayeredPane3.add(jLabel23, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_ano.setEditable(false);
        jTextField_ano.setEnabled(false);
        jTextField_ano.setBounds(260, 200, 40, 20);
        jLayeredPane3.add(jTextField_ano, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel24.setText("Nombre:");
        jLabel24.setBounds(20, 40, 70, 16);
        jLayeredPane3.add(jLabel24, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel25.setText("Apellidos:");
        jLabel25.setBounds(20, 70, 70, 16);
        jLayeredPane3.add(jLabel25, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel26.setText("Domicilio:");
        jLabel26.setBounds(20, 100, 70, 16);
        jLayeredPane3.add(jLabel26, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel27.setText("Telf. Fijo:");
        jLabel27.setBounds(20, 130, 70, 16);
        jLayeredPane3.add(jLabel27, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel28.setText("Telf. Movil:");
        jLabel28.setBounds(200, 130, 70, 16);
        jLayeredPane3.add(jLabel28, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel29.setText("/");
        jLabel29.setBounds(250, 200, 10, 16);
        jLayeredPane3.add(jLabel29, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_email.setEditable(false);
        jTextField_email.setEnabled(false);
        jTextField_email.setBounds(100, 160, 260, 20);
        jLayeredPane3.add(jTextField_email, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_dia.setEditable(false);
        jTextField_dia.setEnabled(false);
        jTextField_dia.setBounds(160, 200, 40, 20);
        jLayeredPane3.add(jTextField_dia, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_mes.setEditable(false);
        jTextField_mes.setEnabled(false);
        jTextField_mes.setBounds(210, 200, 40, 20);
        jLayeredPane3.add(jTextField_mes, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel30.setText("Email:");
        jLabel30.setBounds(20, 160, 50, 16);
        jLayeredPane3.add(jLabel30, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel31.setText("/");
        jLabel31.setBounds(200, 200, 10, 16);
        jLayeredPane3.add(jLabel31, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_Nombre.setEditable(false);
        jTextField_Nombre.setEnabled(false);
        jTextField_Nombre.setBounds(100, 40, 140, 20);
        jLayeredPane3.add(jTextField_Nombre, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_Apellido.setEditable(false);
        jTextField_Apellido.setEnabled(false);
        jTextField_Apellido.setBounds(100, 70, 260, 20);
        jLayeredPane3.add(jTextField_Apellido, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_domicilio.setEditable(false);
        jTextField_domicilio.setEnabled(false);
        jTextField_domicilio.setBounds(100, 100, 260, 20);
        jLayeredPane3.add(jTextField_domicilio, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_telefonofijo.setEditable(false);
        jTextField_telefonofijo.setEnabled(false);
        jTextField_telefonofijo.setBounds(100, 130, 90, 20);
        jLayeredPane3.add(jTextField_telefonofijo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField_telmovil.setEditable(false);
        jTextField_telmovil.setEnabled(false);
        jTextField_telmovil.setBounds(270, 130, 90, 20);
        jLayeredPane3.add(jTextField_telmovil, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Medico Cabecera"));

        jLabel16.setText("Nif");

        jLabel32.setText("Especialidad");

        jLabel33.setText("Nombre");

        jLabel34.setText("Apellidos");

        jComboBox4.setEditable(true);
        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Cabecera", " " }));
        jComboBox4.setEnabled(false);

        jTextField_med_Nif1.setEnabled(false);

        jTextField_medi_Nombre1.setEnabled(false);

        jTextField_medi_apellidos1.setEnabled(false);

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jTextField_med_Nif1)
                    .add(jComboBox4, 0, 101, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jLabel34, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jLabel33, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(9, 9, 9)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jTextField_medi_Nombre1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                    .add(jTextField_medi_apellidos1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextField_medi_Nombre1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jTextField_med_Nif1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel16)
                    .add(jLabel33))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jComboBox4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel32)
                        .add(jTextField_medi_apellidos1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jLabel34))
                .add(28, 28, 28))
        );

        jButton_volantes.setText("Volantes");
        jButton_volantes.setEnabled(false);
        jButton_volantes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_volantesActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLayeredPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
                    .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLayeredPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 377, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(29, 29, 29))
            .add(jPanel3Layout.createSequentialGroup()
                .add(jLayeredPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 363, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLayeredPane7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 249, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(30, 30, 30)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jButton_anadircita, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                            .add(jButton_borrarcita, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)))
                    .add(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButton_volantes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jLayeredPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jLayeredPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 242, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4))
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3Layout.createSequentialGroup()
                        .add(40, 40, 40)
                        .add(jButton_anadircita, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jButton_borrarcita, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 41, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jButton_volantes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 43, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .add(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLayeredPane7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                            .add(jLayeredPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 240, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jButton5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 950, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(20, 20, 20)
                .add(jLabel3)
                .add(23, 23, 23)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton5))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_anadircitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_anadircitaActionPerformed
        // TODO add your handling code here:
        if(jTable_citas.getSelectedRow()!= -1 && (jCalendar_citas.getDate().getTime()>(new Date()).getTime() -86400000))
            G_citas.nuevacita(jTable_citas.getSelectedRow(), jCalendar_citas.getDate(), (String)jTable_citas.getValueAt(jTable_citas.getSelectedRow(), 1));
        else
            JOptionPane.showMessageDialog(null, "Para crear una cita debe seleccionar una fecha y una hora en la tabla", "Error Crear Cita", JOptionPane.ERROR_MESSAGE);

}//GEN-LAST:event_jButton_anadircitaActionPerformed

    private void jButton_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_buscarActionPerformed
        //this.C_Citar.obtenerbeneficiariodni(jTextField_selecnif.getText(), jTextField_selecnss.getText());
        G_citas.obtenerbeneficiariodni(jTextField_selecnif.getText(), jTextField_selecnss.getText());
    }//GEN-LAST:event_jButton_buscarActionPerformed

    private void jButton_volantesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_volantesActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jButton_volantesActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        G_citas.cerrar();
    }//GEN-LAST:event_formWindowClosed

    private void jCalendar_citasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCalendar_citasMouseClicked

    }//GEN-LAST:event_jCalendar_citasMouseClicked

    private void jCalendar_citasDateChanged(org.freixas.jcalendar.DateEvent evt) {//GEN-FIRST:event_jCalendar_citasDateChanged
        // TODO add your handling code here:
        G_citas.cambiodia(jCalendar_citas.getDate());
    }//GEN-LAST:event_jCalendar_citasDateChanged

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton_borrarcitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_borrarcitaActionPerformed
        if(jTable_citas.getSelectedRow()!= -1 && (jCalendar_citas.getDate().getTime()>(new Date()).getTime() -86400000))
            G_citas.rechazarcita(jTable_citas.getSelectedRow(), jCalendar_citas.getDate(), (String)jTable_citas.getValueAt(jTable_citas.getSelectedRow(), 1));
        else
            JOptionPane.showMessageDialog(null, "Para crear una cita debe seleccionar una fecha y una hora en la tabla", "Error Crear Cita", JOptionPane.ERROR_MESSAGE);
    }//GEN-LAST:event_jButton_borrarcitaActionPerformed

    /**
    * @param args the command line arguments
    */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton_anadircita;
    private javax.swing.JButton jButton_borrarcita;
    private javax.swing.JButton jButton_buscar;
    private javax.swing.JButton jButton_volantes;
    private org.freixas.jcalendar.JCalendar jCalendar_citas;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JLayeredPane jLayeredPane4;
    private javax.swing.JLayeredPane jLayeredPane5;
    private javax.swing.JLayeredPane jLayeredPane7;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTable jTable_citas;
    private javax.swing.JTextField jTextField_Apellido;
    private javax.swing.JTextField jTextField_Nombre;
    private javax.swing.JTextField jTextField_ano;
    private javax.swing.JTextField jTextField_dia;
    private javax.swing.JTextField jTextField_domicilio;
    private javax.swing.JTextField jTextField_email;
    private javax.swing.JTextField jTextField_med_Nif1;
    private javax.swing.JTextField jTextField_medi_Nombre1;
    private javax.swing.JTextField jTextField_medi_apellidos1;
    private javax.swing.JTextField jTextField_mes;
    private javax.swing.JTextField jTextField_selecnif;
    private javax.swing.JTextField jTextField_selecnss;
    private javax.swing.JTextField jTextField_telefonofijo;
    private javax.swing.JTextField jTextField_telmovil;
    // End of variables declaration//GEN-END:variables

    public void error(int nerror) {
        switch(nerror){
            case 1:
                 JOptionPane.showMessageDialog(null, "El beneficiario introducido no se encuentra disponible", "Error Beneficiario", JOptionPane.ERROR_MESSAGE);
                break;
            case 2:
                 JOptionPane.showMessageDialog(null, "El medico asignado a este Beneficiario no existe", "Error Medico", JOptionPane.ERROR_MESSAGE);
                break;
            case 3:
               JOptionPane.showMessageDialog(null, "Algo raro ha pasao", "Error Beneficiario", JOptionPane.ERROR_MESSAGE);
                break;
            case 4:
                JOptionPane.showMessageDialog(null, "No se ha introducido un dni o un nif", "Error Beneficiario", JOptionPane.ERROR_MESSAGE);
                break;
            case 5:
                JOptionPane.showMessageDialog(null, "La hora seleccionada no esta disponible para una citacion", "Error Cita", JOptionPane.ERROR_MESSAGE);
                break;
            case 6:
                JOptionPane.showMessageDialog(null, "El Usuario ya tiene una cita con el medico a la hora seleccionada", "Error Crear Cita", JOptionPane.ERROR_MESSAGE);
                break;
            case 7:
                JOptionPane.showMessageDialog(null, "Beneficiario, Medico u Horario modificado en otro administrador.", "Error Crear Cita", JOptionPane.ERROR_MESSAGE);
                G_citas.cerrar();
                this.dispose();
                break;
            case 8:
                JOptionPane.showMessageDialog(null, "La hora y fecha seleccionada no corresponde con una cita del beneficiario", "Error Eliminar Cita", JOptionPane.ERROR_MESSAGE);
                break;
            case 9:
                JOptionPane.showMessageDialog(null, "El beneficiario ha sido eliminado de la base de datos", "Error Beneficiario", JOptionPane.ERROR_MESSAGE);
                G_citas.cerrar();
                this.dispose();
        }

    }

    public void activar(boolean opcion){
        jCalendar_citas.setEnabled(opcion);
        jTable_citas.setEnabled(opcion);
        jButton_anadircita.setEnabled(opcion);
        jButton_borrarcita.setEnabled(opcion);

        jButton_volantes.setEnabled(opcion);
    }
    public void mostrar(Beneficiario beneficiario, Medico medico) {
        this.activar(true);
        if(beneficiario!= null && medico != null){
            jTextField_Apellido.setText(beneficiario.getApellidos());
            jTextField_Nombre.setText(beneficiario.getNombre());
            jTextField_ano.setText(beneficiario.getFecha_nacimiento().substring(0, 4));
            jTextField_mes.setText(beneficiario.getFecha_nacimiento().substring(5, 7));
            jTextField_dia.setText(beneficiario.getFecha_nacimiento().substring(8, 10));
            jTextField_email.setText(beneficiario.getEmail());
            jTextField_domicilio.setText(beneficiario.getDomicilio());
            jTextField_selecnif.setText(beneficiario.getNif());
            jTextField_selecnss.setText(beneficiario.getNss());
            jTextField_telefonofijo.setText(""+beneficiario.getTeleFijo());
            jTextField_telmovil.setText(""+beneficiario.getTeleMovil());
            jTextField_med_Nif1.setText(medico.getNif());
            jTextField_medi_Nombre1.setText(medico.getNombre());
            jTextField_medi_apellidos1.setText(medico.getApellidos());
        }
    }

    public void mostrar(String [] estados) {
        for(int i=0; i< estados.length; i++)
            jTable_citas.getModel().setValueAt(estados[i], i, 1);
    }

    public void mostrar(boolean[] estado_citas) {
        for(int i=0; i< estado_citas.length; i++){
            jTable_citas.getModel().setValueAt(estado_citas[i], i, 2);
        }
    }

    public void mostrar(String string) {
        JOptionPane.showMessageDialog(null, string, "Cita Creada", JOptionPane.OK_OPTION);
    }

}
